<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="robots" content="noodp" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
        <title>Cache Line对读写性能的影响 - 负责和大饼的博客</title><meta name="Description" content="想专注于学点手艺"><meta property="og:title" content="Cache Line对读写性能的影响" />
<meta property="og:description" content="Cache Line对读写性能的影响 Cache Line 简介 CPU访问存储器时，无论是存取指令还是存取数据，所访问的存储单元都趋于聚集在一个较小的连续区域中。当我们需" />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://amath0312.github.com/about-cache-line/" />
<meta property="article:published_time" content="2020-11-08T13:41:40+08:00" />
<meta property="article:modified_time" content="2020-11-08T13:41:40+08:00" />
<meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="Cache Line对读写性能的影响"/>
<meta name="twitter:description" content="Cache Line对读写性能的影响 Cache Line 简介 CPU访问存储器时，无论是存取指令还是存取数据，所访问的存储单元都趋于聚集在一个较小的连续区域中。当我们需"/>
<meta name="application-name" content="负责和大饼的博客">
<meta name="apple-mobile-web-app-title" content="负责和大饼的博客"><link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
        <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
        <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"><link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"><link rel="manifest" href="/site.webmanifest"><link rel="canonical" href="https://amath0312.github.com/about-cache-line/" /><link rel="prev" href="https://amath0312.github.com/mysql-master-slave-copy/" /><link rel="next" href="https://amath0312.github.com/epoll-in-redis/" /><link rel="stylesheet" href="/lib/normalize/normalize.min.css"><link rel="stylesheet" href="/css/style.min.css"><link rel="stylesheet" href="/lib/fontawesome-free/all.min.css"><link rel="stylesheet" href="/lib/animate/animate.min.css"><script type="application/ld+json">
    {
        "@context": "http://schema.org",
        "@type": "BlogPosting",
        "headline": "Cache Line对读写性能的影响",
        "inLanguage": "zh-CN",
        "mainEntityOfPage": {
            "@type": "WebPage",
            "@id": "https:\/\/amath0312.github.com\/about-cache-line\/"
        },"genre": "posts","keywords": "java","wordcount":  1344 ,
        "url": "https:\/\/amath0312.github.com\/about-cache-line\/","datePublished": "2020-11-08T13:41:40+08:00","dateModified": "2020-11-08T13:41:40+08:00","publisher": {
            "@type": "Organization",
            "name": "负责和大饼"},"author": {
                "@type": "Person",
                "name": "负责和大饼"
            },"description": ""
    }
    </script></head>
    <body header-desktop="" header-mobile=""><script type="text/javascript">(window.localStorage && localStorage.getItem('theme') ? localStorage.getItem('theme') === 'dark' : ('' === 'auto' ? window.matchMedia('(prefers-color-scheme: dark)').matches : '' === 'dark')) && document.body.setAttribute('theme', 'dark');</script>

        <div id="mask"></div><div class="wrapper"><header class="desktop" id="header-desktop">
    <div class="header-wrapper">
        <div class="header-title">
            <a href="/" title="负责和大饼的博客">负责和大饼的博客</a>
        </div>
        <div class="menu">
            <div class="menu-inner"><a class="menu-item" href="/posts/"> Blog </a><a class="menu-item" href="/categories/"> Categories </a><a class="menu-item" href="/tags/"> Tags </a><a class="menu-item" href="/about/"> About </a><span class="menu-item delimiter"></span><span class="menu-item search" id="search-desktop">
                        <input type="text" placeholder="Search titles or contents..." id="search-input-desktop">
                        <a href="javascript:void(0);" class="search-button search-toggle" id="search-toggle-desktop" title="Search">
                            <i class="fas fa-search fa-fw"></i>
                        </a>
                        <a href="javascript:void(0);" class="search-button search-clear" id="search-clear-desktop" title="Clear">
                            <i class="fas fa-times-circle fa-fw"></i>
                        </a>
                        <span class="search-button search-loading" id="search-loading-desktop">
                            <i class="fas fa-spinner fa-fw fa-spin"></i>
                        </span>
                    </span><a href="javascript:void(0);" class="menu-item theme-switch" title="Switch Theme">
                    <i class="fas fa-adjust fa-fw"></i>
                </a>
            </div>
        </div>
    </div>
</header><header class="mobile" id="header-mobile">
    <div class="header-container">
        <div class="header-wrapper">
            <div class="header-title">
                <a href="/" title="负责和大饼的博客">负责和大饼的博客</a>
            </div>
            <div class="menu-toggle" id="menu-toggle-mobile">
                <span></span><span></span><span></span>
            </div>
        </div>
        <div class="menu" id="menu-mobile"><div class="search-wrapper">
                    <div class="search mobile" id="search-mobile">
                        <input type="text" placeholder="Search titles or contents..." id="search-input-mobile">
                        <a href="javascript:void(0);" class="search-button search-toggle" id="search-toggle-mobile" title="Search">
                            <i class="fas fa-search fa-fw"></i>
                        </a>
                        <a href="javascript:void(0);" class="search-button search-clear" id="search-clear-mobile" title="Clear">
                            <i class="fas fa-times-circle fa-fw"></i>
                        </a>
                        <span class="search-button search-loading" id="search-loading-mobile">
                            <i class="fas fa-spinner fa-fw fa-spin"></i>
                        </span>
                    </div>
                    <a href="javascript:void(0);" class="search-cancel" id="search-cancel-mobile">
                        Cancel
                    </a>
                </div><a class="menu-item" href="/posts/" title="">Blog</a><a class="menu-item" href="/categories/" title="">Categories</a><a class="menu-item" href="/tags/" title="">Tags</a><a class="menu-item" href="/about/" title="">About</a><a href="javascript:void(0);" class="menu-item theme-switch" title="Switch Theme">
                <i class="fas fa-adjust fa-fw"></i>
            </a></div>
    </div>
</header>
<div class="search-dropdown desktop">
    <div id="search-dropdown-desktop"></div>
</div>
<div class="search-dropdown mobile">
    <div id="search-dropdown-mobile"></div>
</div>
<main class="main">
                <div class="container"><div class="toc" id="toc-auto">
            <h2 class="toc-title">Contents</h2>
            <div class="toc-content" id="toc-content-auto"></div>
        </div><article class="page single"><h1 class="single-title animated flipInX">Cache Line对读写性能的影响</h1><div class="post-meta">
            <div class="post-meta-line"><span class="post-author"><a href="/" title="Author" rel=" author" class="author"><i class="fas fa-user-circle fa-fw"></i>负责和大饼</a></span>&nbsp;<span class="post-category">included in <a href="/categories/java/"><i class="far fa-folder fa-fw"></i>java</a>&nbsp;<a href="/categories/dev/"><i class="far fa-folder fa-fw"></i>dev</a></span></div>
            <div class="post-meta-line"><i class="far fa-calendar-alt fa-fw"></i>&nbsp;<time datetime="2020-11-08">2020-11-08</time>&nbsp;<i class="fas fa-pencil-alt fa-fw"></i>&nbsp;1344 words&nbsp;
                <i class="far fa-clock fa-fw"></i>&nbsp;3 minutes&nbsp;</div>
        </div><div class="details toc" id="toc-static"  kept="">
                <div class="details-summary toc-title">
                    <span>Contents</span>
                    <span><i class="details-icon fas fa-angle-right"></i></span>
                </div>
                <div class="details-content toc-content" id="toc-content-static"><nav id="TableOfContents">
  <ul>
    <li><a href="#cache-line-简介">Cache Line 简介</a></li>
    <li><a href="#伪共享">伪共享</a></li>
    <li><a href="#对齐填充">对齐填充</a></li>
    <li><a href="#测试代码">测试代码</a></li>
  </ul>
</nav></div>
            </div><div class="content" id="content"><h1 id="cache-line对读写性能的影响">Cache Line对读写性能的影响</h1>
<h2 id="cache-line-简介">Cache Line 简介</h2>
<p><img
        class="lazyload"
        src="/svg/loading.min.svg"
        data-src="assets/cpu-cache-arch.png"
        data-srcset="/about-cache-line/assets/cpu-cache-arch.png, assets/cpu-cache-arch.png 1.5x, /about-cache-line/assets/cpu-cache-arch.png 2x"
        data-sizes="auto"
        alt="/about-cache-line/assets/cpu-cache-arch.png"
        title="CPU缓存架构" /></p>
<p>CPU访问存储器时，无论是存取指令还是存取数据，所访问的存储单元都趋于聚集在一个较小的连续区域中。当我们需要从内存中读取一个int变量i的值时，CPUb不会仅将这个4字节的i加载到缓存。计算机认为程序接下来很大概率会访问相邻的数据，于是会把相邻的数据给一块儿加载到缓存中，下次再读取时，就不用访问主存了，直接从缓存中读取就可以了，减少了CPU访问主存的次数，提高缓存的命中率。</p>
<p>CPU读取数据时，总是会一个块一个块的读，哪怕你需要的仅仅是1个字节的数据，这个【块】就被称为【Cache Line】。
<strong>不同的CPU，Cache Line大小是不一样的，Intel的CPU大部分都是64字节。</strong></p>
<p>多级缓存就是由若干个Cache Line组成的，CPU每次从主存中拉取数据时，会把相邻的数据也存入同一个Cache Line。</p>
<h2 id="伪共享">伪共享</h2>
<p>当多个线程去同时读写共享变量时，由于缓存一致性协议，只要Cache Line中任一数据失效，整个Cache  Line就会被置为失效。这就会导致本来相互不影响的数据，由于被分配在同一个Cache Line中，双方在写数据时，导致对方的Cache  Line不断失效，无法利用Cache Line缓存特性的现象就被称为【伪共享】。</p>
<p>例如，启动两个线程，分别修改共享变量<code>long a</code>和<code>long b</code>，由于a和b一共占用16字节，可以被分配进同一个Cache  Line中。本来互相不影响的两个线程修改数据，由于a和b被分配到同一个Cache Line中，将导致对方的Cache  Line不断失效，不断的重新发起load指令重主存中重新加载数据，降低程序的性能。</p>
<h2 id="对齐填充">对齐填充</h2>
<p>要想解决伪共享问题也很简单，既然一个Cache Line存放64字节的数据，只要在a和b变量之间填充7个无意义的Long变量，占满64字节，这样a和b就无法被分配进同一个Cache Line中，线程之间修改数据互不影响，就没有上面的问题了。</p>
<p>Cache Line对齐其实是一种比较low的解决办法，因为你无法判断你写的程序会被放到哪种CPU上运行，不同的CPU它的Cache Line大小是不一样的，如果超过了64字节，填充7个long变量就没有效果了。因此，JDK8引入了一个新的注解<code>@sun.misc.Contended</code>，被它修饰的变量，会被存放到一个单独的Cache Line中，不会和其他变量共享Cache Line。</p>
<blockquote>
<p>JDK8的老版本中@Contended默认是禁用的，需要手动开启：<code>-XX:-RestrictContended</code>。</p>
</blockquote>
<h2 id="测试代码">测试代码</h2>
<div class="highlight"><pre class="chroma"><code class="language-java" data-lang="java"><span class="kn">package</span> <span class="nn">beer.coder.woc.awesome</span><span class="o">;</span>

<span class="kn">import</span> <span class="nn">sun.misc.Contended</span><span class="o">;</span>

<span class="kn">import</span> <span class="nn">java.util.Random</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">java.util.concurrent.CountDownLatch</span><span class="o">;</span>

<span class="kd">public</span> <span class="kd">class</span> <span class="nc">TestCacheLine</span> <span class="o">{</span>

    <span class="kd">public</span> <span class="kd">static</span> <span class="kt">void</span> <span class="nf">main</span><span class="o">(</span><span class="n">String</span><span class="o">[]</span> <span class="n">args</span><span class="o">)</span> <span class="kd">throws</span> <span class="n">InterruptedException</span> <span class="o">{</span>
        <span class="kt">int</span><span class="o">[]</span> <span class="n">arr</span> <span class="o">=</span> <span class="k">new</span> <span class="kt">int</span><span class="o">[</span><span class="n">128</span> <span class="o">*</span> <span class="n">1024</span> <span class="o">*</span> <span class="n">1024</span><span class="o">];</span>
        <span class="n">Random</span> <span class="n">random</span> <span class="o">=</span> <span class="k">new</span> <span class="n">Random</span><span class="o">(</span><span class="n">System</span><span class="o">.</span><span class="na">currentTimeMillis</span><span class="o">());</span>
        <span class="k">for</span> <span class="o">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="n">0</span><span class="o">;</span> <span class="n">i</span> <span class="o">&lt;</span> <span class="n">arr</span><span class="o">.</span><span class="na">length</span><span class="o">;</span> <span class="n">i</span><span class="o">++)</span> <span class="o">{</span>
            <span class="n">arr</span><span class="o">[</span><span class="n">i</span><span class="o">]</span> <span class="o">=</span> <span class="n">random</span><span class="o">.</span><span class="na">nextInt</span><span class="o">();</span>
        <span class="o">}</span>
        <span class="kt">long</span> <span class="n">temp</span> <span class="o">=</span> <span class="n">0</span><span class="o">;</span>

        <span class="n">TimerTick</span> <span class="n">timer</span> <span class="o">=</span> <span class="n">TimerTick</span><span class="o">.</span><span class="na">timer</span><span class="o">();</span>
        <span class="k">for</span> <span class="o">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="n">0</span><span class="o">;</span> <span class="n">i</span> <span class="o">&lt;</span> <span class="n">arr</span><span class="o">.</span><span class="na">length</span> <span class="o">/</span> <span class="n">16</span><span class="o">;</span> <span class="n">i</span> <span class="o">+=</span> <span class="n">1</span><span class="o">)</span> <span class="o">{</span>
            <span class="n">temp</span> <span class="o">+=</span> <span class="n">arr</span><span class="o">[</span><span class="n">i</span><span class="o">];</span>
        <span class="o">}</span>
        <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">timer</span><span class="o">.</span><span class="na">duration</span><span class="o">());</span>

        <span class="n">timer</span><span class="o">.</span><span class="na">restart</span><span class="o">();</span>
        <span class="k">for</span> <span class="o">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="n">0</span><span class="o">;</span> <span class="n">i</span> <span class="o">&lt;</span> <span class="n">arr</span><span class="o">.</span><span class="na">length</span><span class="o">;</span> <span class="n">i</span> <span class="o">+=</span> <span class="n">16</span><span class="o">)</span> <span class="o">{</span>
            <span class="n">temp</span> <span class="o">+=</span> <span class="n">arr</span><span class="o">[</span><span class="n">i</span><span class="o">];</span>
        <span class="o">}</span>
        <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">timer</span><span class="o">.</span><span class="na">duration</span><span class="o">());</span>

        <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">arr</span><span class="o">.</span><span class="na">length</span><span class="o">);</span>
        <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">temp</span><span class="o">);</span>


        <span class="kt">long</span> <span class="n">length</span> <span class="o">=</span> <span class="n">128L</span> <span class="o">*</span> <span class="n">1024</span> <span class="o">*</span> <span class="n">1024</span><span class="o">;</span>
        <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="s">&#34;loop: &#34;</span> <span class="o">+</span> <span class="n">length</span><span class="o">);</span>

        <span class="o">{</span>
            <span class="n">CountDownLatch</span> <span class="n">latch</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CountDownLatch</span><span class="o">(</span><span class="n">2</span><span class="o">);</span>
            <span class="n">timer</span><span class="o">.</span><span class="na">restart</span><span class="o">();</span>
            <span class="n">PaddingData</span> <span class="n">data</span> <span class="o">=</span> <span class="k">new</span> <span class="n">PaddingData</span><span class="o">();</span>
            <span class="k">new</span> <span class="n">Thread</span><span class="o">(()</span> <span class="o">-&gt;</span> <span class="o">{</span>
                <span class="n">Random</span> <span class="n">r</span> <span class="o">=</span> <span class="k">new</span> <span class="n">Random</span><span class="o">(</span><span class="n">System</span><span class="o">.</span><span class="na">currentTimeMillis</span><span class="o">());</span>
                <span class="k">for</span> <span class="o">(</span><span class="kt">long</span> <span class="n">i</span> <span class="o">=</span> <span class="n">0</span><span class="o">;</span> <span class="n">i</span> <span class="o">&lt;</span> <span class="n">length</span><span class="o">;</span> <span class="n">i</span><span class="o">++)</span> <span class="o">{</span>
                    <span class="n">data</span><span class="o">.</span><span class="na">a</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="na">nextLong</span><span class="o">();</span>
                <span class="o">}</span>
                <span class="n">latch</span><span class="o">.</span><span class="na">countDown</span><span class="o">();</span>
            <span class="o">}).</span><span class="na">start</span><span class="o">();</span>
            <span class="k">new</span> <span class="n">Thread</span><span class="o">(()</span> <span class="o">-&gt;</span> <span class="o">{</span>
                <span class="n">Random</span> <span class="n">r</span> <span class="o">=</span> <span class="k">new</span> <span class="n">Random</span><span class="o">(</span><span class="n">System</span><span class="o">.</span><span class="na">currentTimeMillis</span><span class="o">());</span>
                <span class="k">for</span> <span class="o">(</span><span class="kt">long</span> <span class="n">i</span> <span class="o">=</span> <span class="n">0</span><span class="o">;</span> <span class="n">i</span> <span class="o">&lt;</span> <span class="n">length</span><span class="o">;</span> <span class="n">i</span><span class="o">++)</span> <span class="o">{</span>
                    <span class="n">data</span><span class="o">.</span><span class="na">b</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="na">nextLong</span><span class="o">();</span>
                <span class="o">}</span>
                <span class="n">latch</span><span class="o">.</span><span class="na">countDown</span><span class="o">();</span>
            <span class="o">}).</span><span class="na">start</span><span class="o">();</span>
            <span class="n">latch</span><span class="o">.</span><span class="na">await</span><span class="o">();</span>
            <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="s">&#34;padding: &#34;</span> <span class="o">+</span> <span class="n">timer</span><span class="o">.</span><span class="na">duration</span><span class="o">());</span>
        <span class="o">}</span>

        <span class="o">{</span>
            <span class="n">CountDownLatch</span> <span class="n">latch</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CountDownLatch</span><span class="o">(</span><span class="n">2</span><span class="o">);</span>
            <span class="n">timer</span><span class="o">.</span><span class="na">restart</span><span class="o">();</span>
            <span class="n">Data</span> <span class="n">data</span> <span class="o">=</span> <span class="k">new</span> <span class="n">Data</span><span class="o">();</span>
            <span class="k">new</span> <span class="n">Thread</span><span class="o">(()</span> <span class="o">-&gt;</span> <span class="o">{</span>
                <span class="n">Random</span> <span class="n">r</span> <span class="o">=</span> <span class="k">new</span> <span class="n">Random</span><span class="o">(</span><span class="n">System</span><span class="o">.</span><span class="na">currentTimeMillis</span><span class="o">());</span>
                <span class="k">for</span> <span class="o">(</span><span class="kt">long</span> <span class="n">i</span> <span class="o">=</span> <span class="n">0</span><span class="o">;</span> <span class="n">i</span> <span class="o">&lt;</span> <span class="n">length</span><span class="o">;</span> <span class="n">i</span><span class="o">++)</span> <span class="o">{</span>
                    <span class="n">data</span><span class="o">.</span><span class="na">a</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="na">nextLong</span><span class="o">();</span>
                <span class="o">}</span>
                <span class="n">latch</span><span class="o">.</span><span class="na">countDown</span><span class="o">();</span>
            <span class="o">}).</span><span class="na">start</span><span class="o">();</span>
            <span class="k">new</span> <span class="n">Thread</span><span class="o">(()</span> <span class="o">-&gt;</span> <span class="o">{</span>
                <span class="n">Random</span> <span class="n">r</span> <span class="o">=</span> <span class="k">new</span> <span class="n">Random</span><span class="o">(</span><span class="n">System</span><span class="o">.</span><span class="na">currentTimeMillis</span><span class="o">());</span>
                <span class="k">for</span> <span class="o">(</span><span class="kt">long</span> <span class="n">i</span> <span class="o">=</span> <span class="n">0</span><span class="o">;</span> <span class="n">i</span> <span class="o">&lt;</span> <span class="n">length</span><span class="o">;</span> <span class="n">i</span><span class="o">++)</span> <span class="o">{</span>
                    <span class="n">data</span><span class="o">.</span><span class="na">b</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="na">nextLong</span><span class="o">();</span>
                <span class="o">}</span>
                <span class="n">latch</span><span class="o">.</span><span class="na">countDown</span><span class="o">();</span>
            <span class="o">}).</span><span class="na">start</span><span class="o">();</span>
            <span class="n">latch</span><span class="o">.</span><span class="na">await</span><span class="o">();</span>
            <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="s">&#34;no padding: &#34;</span> <span class="o">+</span> <span class="n">timer</span><span class="o">.</span><span class="na">duration</span><span class="o">());</span>
        <span class="o">}</span>


    <span class="o">}</span>

    <span class="kd">static</span> <span class="kd">class</span> <span class="nc">Data</span> <span class="o">{</span>
        <span class="kd">volatile</span> <span class="kt">long</span> <span class="n">a</span><span class="o">;</span>
        <span class="kd">volatile</span> <span class="kt">long</span> <span class="n">b</span><span class="o">;</span>
    <span class="o">}</span>

    <span class="kd">static</span> <span class="kd">class</span> <span class="nc">PaddingData</span> <span class="o">{</span>
        <span class="nd">@Contended</span>
        <span class="kd">volatile</span> <span class="kt">long</span> <span class="n">a</span><span class="o">;</span>
        <span class="nd">@Contended</span>
        <span class="kd">volatile</span> <span class="kt">long</span> <span class="n">b</span><span class="o">;</span>
    <span class="o">}</span>
<span class="o">}</span>

</code></pre></div><p>参考文章：<a href="https://blog.csdn.net/qq_32099833/article/details/108927025" target="_blank" rel="noopener noreffer">Cache Line对数据读写性能的影响</a></p>
</div><div class="post-footer" id="post-footer">
    <div class="post-info">
        <div class="post-info-line">
            <div class="post-info-mod">
                <span>Updated on 2020-11-08</span>
            </div>
            <div class="post-info-license"></div>
        </div>
        <div class="post-info-line">
            <div class="post-info-md"></div>
            <div class="post-info-share">
                <span></span>
            </div>
        </div>
    </div>

    <div class="post-info-more">
        <section class="post-tags"><i class="fas fa-tags fa-fw"></i>&nbsp;<a href="/tags/java/">java</a></section>
        <section>
            <span><a href="javascript:void(0);" onclick="window.history.back();">Back</a></span>&nbsp;|&nbsp;<span><a href="/">Home</a></span>
        </section>
    </div>

    <div class="post-nav"><a href="/mysql-master-slave-copy/" class="prev" rel="prev" title="MySQL- 技术专题 - 主从复制原理"><i class="fas fa-angle-left fa-fw"></i>MySQL- 技术专题 - 主从复制原理</a>
            <a href="/epoll-in-redis/" class="next" rel="next" title="Redis中的多路复用机制">Redis中的多路复用机制<i class="fas fa-angle-right fa-fw"></i></a></div>
</div>
</article></div>
            </main><footer class="footer">
        <div class="footer-container"><div class="footer-line">Powered by <a href="https://gohugo.io/" target="_blank" rel="noopener noreffer" title="Hugo 0.75.1">Hugo</a> | Theme - <a href="https://github.com/dillonzq/LoveIt" target="_blank" rel="noopener noreffer" title="LoveIt 0.2.10"><i class="far fa-kiss-wink-heart fa-fw"></i> LoveIt</a>
                </div><div class="footer-line"><i class="far fa-copyright fa-fw"></i><span itemprop="copyrightYear">2019 - 2020</span><span class="author" itemprop="copyrightHolder">&nbsp;<a href="/" target="_blank"></a></span>&nbsp;|&nbsp;<span class="license">本文采用<a rel="license" href="http://creativecommons.org/licenses/by-nc/4.0/" target="_blank">知识共享署名-非商业性使用 4.0 国际许可协议</a>进行许可</span></div>
        </div>
    </footer></div>

        <div id="fixed-buttons"><a href="#" id="back-to-top" class="fixed-button" title="Back to Top">
                <i class="fas fa-arrow-up fa-fw"></i>
            </a><a href="#" id="view-comments" class="fixed-button" title="View Comments">
                <i class="fas fa-comment fa-fw"></i>
            </a>
        </div><script type="text/javascript" src="/lib/smooth-scroll/smooth-scroll.min.js"></script><script type="text/javascript" src="/lib/autocomplete/autocomplete.min.js"></script><script type="text/javascript" src="/lib/algoliasearch/algoliasearch-lite.umd.min.js"></script><script type="text/javascript" src="/lib/lazysizes/lazysizes.min.js"></script><script type="text/javascript" src="/lib/clipboard/clipboard.min.js"></script><script type="text/javascript">window.config={"code":{"copyTitle":"Copy to clipboard","maxShownLines":10},"comment":{},"search":{"algoliaAppID":"JJRDOPDPLW","algoliaIndex":"amath_blog","algoliaSearchKey":"e529bedc6a3af35b53e2597f1c7550c2","highlightTag":"em","maxResultLength":10,"noResultsFound":"No results found","snippetLength":50,"type":"algolia"}};</script><script type="text/javascript" src="/js/theme.min.js"></script></body>
</html>
